package com.kandinfo.base.admin.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.kandinfo.base.admin.domain.ScheduleJob;


public class QuartzJobFactory implements Job {
    public final Logger log = LoggerFactory.getLogger(QuartzJobFactory.class);

    public void execute(JobExecutionContext context) throws JobExecutionException {
        ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get("scheduleJob");
        String jobName = context.getJobDetail().getKey().getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("---" + jobName + " 在[ " + dateFormat.format(new Date())+ " ] 执行!!  ");
        TaskUtils.invokMethod(scheduleJob);
    }
}
